<section class="panel">
	<div class="row text-sm wrapper">
		<div class="col-sm-4">
			<div class="input-group">
				<input type="text" class="input-sm form-control" placeholder="Search">
				<span class="input-group-btn">
					<button class="btn btn-sm btn-info" type="button">Go!</button>
				</span>
			</div>
		</div>
		<div class="col-lg-4">
			<div class="doc-buttons">
				<a href="<?php echo site_url('admin/adUserM/tambahUser');?>"><button class="btn btn-sm btn-info"><i class="fa fa-pencil text"></i>
					<span class="text"> Tambah</span></button></a>
			</div>
		</div>			
	</div>
<div class="table-responsive">
	<table class="table table-striped b-t text-sm">
		<thead>
			<tr>
				<th class="th-sortable" data-toggle="class">ID</th>
				<th>Nama lengkap
					<span class="th-sort">
						<i class="fa fa-sort-down text"></i>
						<i class="fa fa-sort-up text-active"></i>
						<i class="fa fa-sort"></i>
					</span>				
				</th>
				<th>Username</th>
				<th>Role</th>
				<th>Status</th>
				<th><a href="<?php echo site_url('admin/aduserm/lihatUser')?>">Lihat</a></th>
				<th><a href="<?php echo site_url('admin/aduserm/editUser')?>">Ubah</a></th>
		  </tr>
		</thead>
		<tbody>
			<?php
				foreach($users as $user)
				{
					switch($user['ROLE'])
					{
						default:
							$role = "Kosong";
							break;
						case 1:
							$role = "Administrator";	
							break;
						case 2:
							$role = "Pencetak Legalisir";
							break;
						case 3:
							$role = "Verifikator";
							break;
						/* case 4:
							$role = "Kepala Dinas";
							break;
						case 5:
							$role = "Sekretaris";
							break; */
					}
					
					switch($user['STATUS'])
					{
						case 1:
							$stat = "Aktif";
							break;
						case 0:
							$stat = "Tidak Aktif";
							break;
					}
					
					echo "<tr>";
					echo "<td>$user[ID_USER]</td>";
					echo "<td>$user[NAMA_LENGKAP]</td>";
					echo "<td>$user[USERNAME]</td>";
					echo "<td>$role</td>";
					echo "<td>$stat</td>";
					echo "<td><a href=".site_url("admin/aduserm/lihatUser?id=$user[ID_USER]").">Lihat</a></td>";
					echo "<td><a href=".site_url("admin/aduserm/editUser?id=$user[ID_USER]").">Ubah</a></td>";
					echo "</tr>";
				}
			?>
		</tbody>
	</table>
</div>
<footer class="panel-footer">
	<div class="row">
		<div class="col-sm-4 text-left">
			<small class="text-muted inline m-t-sm m-b-sm"><?php
				$itemPerPage = 5;
				$page=1;
				if($_SERVER['QUERY_STRING'] != null){
					$page = explode('=', $_SERVER['QUERY_STRING']);
					$page = $page[1];
				}
				$first = ($itemPerPage * ($page-1)) + 1;
				$last = $first + $itemPerPage - 1;
				if($last > $total)
					$last = $total;
				echo "showing $first-$last of $total items";
			?></small>
		</div>
		<div class="col-sm-4 text-right text-center-xs pull-right">                
			<ul class="pagination pagination-sm m-t-none m-b-none">
				<li><a href="<?php
					$page=1;
					if($_SERVER['QUERY_STRING'] != null){
						$page = explode('=', $_SERVER['QUERY_STRING']);
						$page = $page[1];
					}
					if($page > 1){
						$page--;
						echo "?page=$page";
					}
					else
						echo "#";
				?>"><i class="fa fa-chevron-left"></i></a></li>
				<?php
					$pages = ceil($total/$itemPerPage);
					for($i = 1; $i <= $pages; $i++){
						echo "<li><a href=?page=$i>$i</a></li>";
					}
				?>
				<li><a href="<?php
					$page=1;
					if($_SERVER['QUERY_STRING'] != null){
						$page = explode('=', $_SERVER['QUERY_STRING']);
						$page = $page[1];
					}
					if($page < ceil($total/$itemPerPage)){
						$page++;
						echo "?page=$page";
					}
					else
						echo "#";
				?>"><i class="fa fa-chevron-right"></i></a></li>
			</ul>
		</div>
	</div>
</footer>
</section>